$(document).ready(function() {
$("#country").select2({
	minimumInputLength: 0,
	ajax: {
		url: "data.php",
		dataType: 'json',
		data: function (term) {
			return {
				action: 'country',
				query: term
			};
		},
		results: function (data) {
			return { results: data };
		}
	}				
});

$("#state").select2({
	minimumInputLength: 0,
	ajax: {
		url: "data.php",
		dataType: 'json',
		data: function (term) {
			return {
				action: 'state',
				country_id: $('#country').val(),
				query: term
			};
		},
		results: function (data) {
			return { results: data };
		}
	}								
});	

});






jQuery(function() 
{ 
    $('#r_name').select2({
		placeholder: "Search Name",
		minimumInputLength: 3,
		multiple: false,
		quietMillis: 100,
		id: function(bond){ return bond.ID;},
		ajax: {
				url: "SearchDetailEmp",
				dataType: 'json',
				type: 'POST',
				data: function(term, page) 
				{
					return {
								SearchName: term,
								page: page || 1
							}
				},
				results: function(bond, page) 
				{
					return {results: bond.Show_Name, more: (bond.Show_Name && bond.Show_Name.length == 10 ? true: false)}
				}
				},
				formatResult: function(bond) {return '<div class="select2-user-result">' + bond.NAME + '</div>'},
				formatSelection: function(bond){return bond.NAME},
				initSelection: function(elem, cb){return elem}
    })
})